#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle(c_strTitle);
}

bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
    MSG *param = static_cast<MSG *>(message);

    switch (param->message)
    {
        case WM_COPYDATA:
        {
            COPYDATASTRUCT *cds = reinterpret_cast<COPYDATASTRUCT*>(param->lParam);
            if (cds->dwData == CUSTOM_TYPE)
            {
                QString strMessage = QString::fromUtf8(reinterpret_cast<char*>(cds->lpData), cds->cbData);
                QMessageBox::information(this, QStringLiteral("提示"), strMessage);
                *result = 1;
                return true;
            }
        }
    }

    return QWidget::nativeEvent(eventType, message, result);
}

MainWindow::~MainWindow()
{
    delete ui;
}
